@extends('admin.master')

@section('style')
	<link rel="stylesheet" href="{{ url('css/bootstrap-datetimepicker.css') }}">
	<link rel="stylesheet" href="{{ url('js/bootstrap-select/bootstrap-select.min.css') }}">
@endsection

@section('top')
	<div class="top-breadcrumb pull-left">{!! Breadcrumbs::render() !!}</div>
	<div class="top-btn-group pull-right">
		<a href="{{ route('admin.other-order.create') }}" class="btn btn-primary">
			<i class="fa fa-plus" aria-hidden="true"></i> 添加订单
		</a>
	</div>
@endsection

@section('content')
<div class="section-search mb10">
	{!! Form::model($where, ['method'=>'get', 'class'=>'form-inline']) !!}
	<div class="form-group">
		{!! Form::text('word', null, ['class'=>'form-control len wd-search', 'id'=>'kw', 'placeholder'=>'客户名称或域名']) !!}
	</div>
	<div class="form-group">
		<label class="control-label">订单类型：</label>
		{!! Form::select('type', ['选择类型']+config('system.other_order_type'), null, ['class'=>'form-control len100 selectpicker show-tick']) !!}
	</div>
	<div class="form-group">
		<label class="control-label">设计师：</label>
		{!! Form::select('designer_id', $designer, null, ['class'=>'form-control selectpicker len100']) !!}
	</div>
	<div class="form-group">
		<label class="control-label">状态：</label>
		{!! Form::select('status', ['选择状态']+config('system.other_order_status'), null, ['class'=>'form-control']) !!}
	</div>
	<div class="form-group">
		{!! Form::select('date_field', array_slice(config('system.dateTypeFull'), 1, null, true), null, ['class'=>'form-control autosize date-type-select']) !!}
		<div class="form-datetime datetime-search len150">
			{!! Form::text('start', null, ['class'=>'form-control len150 datetimepicker-start', 'data-date-format'=>'yyyy-mm-dd']) !!}
			<i class="icon icon-date"></i>
		</div>
		<span class="date-step-span">至</span>
		<div class="form-datetime datetime-search len150">
			{!! Form::text('end', null, ['class'=>'form-control len150 datetimepicker-end', 'data-date-format'=>'yyyy-mm-dd']) !!}
			<i class="icon icon-date"></i>
		</div>
	</div>
	<button type="submit" class="btn btn-default">查询</button>
{!! Form::close() !!}
</div>
<div class="gridSection">
<table class="table table-hover table-list" id="customer-list">
		<thead>
			<tr>
				<th class="text-center">序号</th>
				<th>客户名称</th>
				<th>下单时间</th>
				<th>开始生产时间</th>
				<th>完成时间</th>
				<th>订单类型</th>
				<th>生产类型</th>
				<th>标签</th>
				<th class="text-center">周期</th>
				<th>域名</th>
				<th>设计师</th>
				<th>提成</th>
				<th>具体进度</th>
				<th>状态</th>
				<th class="text-right">操作</th>
			</tr>
		</thead>
		<tbody>
		@if (!$data->isEmpty())
			@foreach ($data as $value)
				<tr data-id="{{ $value->id }}">
					<td class="text-center">{{ $i++ }}</td>
					<td>
						@if (($value->ptype < 3) && (!$value->is_end))
							<span class="text-warning">{{ $value->name }}</span>
						@else
							{{ $value->name }}
						@endif
					</td>
					<td>{{ $value->created_at->format('Y-m-d') }}</td>
					<td>
						<span class="text-success">
							{{ $value->started_at->toDateString() > 0 ? $value->started_at->format('Y-m-d') : '' }}
						</span>
					</td>
					<td>
						@if ($value->status == 3 && $value->finished_at->toDateTimeString() > 0)
							<span class="text-success">{{ $value->finished_at->format('Y-m-d') }}</span>
						@endif
					</td>
					<td class="{{ $value->ptype < 3 ? 'success' : '' }}">
						<span>{{ array_flatten_keep(config('system.other_order_type'))[$value->type] }}</span>
					</td>
					<td>
						<span class="label label-{{ ['success', 'primary', 'default'][$value->ptype-1] }}">{{ config('system.ptype')[$value->ptype] }}</span>
					</td>
					<td>{{ $value->label }}</td>
					<td class="text-center"><span class="text-success">{{ $value->days }}</span></td>
					<td><a href="http://{{ str_replace('http://', '', $value->domain) }}" target="_blank">{{ str_replace('http://', '', $value->domain) }}</a></td>
					<td>
						@if($value->designer)
							<span class="label label-success" title="设计师">{{ $value->designer->name or '' }}</span>
						@endif
						@if ($value->programmer)
							<span class="label label-info" title="制作员">{{ $value->programmer->name or '' }}</span>
						@endif
						@if ($value->inputer)
							<span class="label label-warning" title="录入员">{{ $value->inputer->name or '' }}</span>
						@endif
					</td>
					<td><span class="text-warning">￥{{ $value->commission }}</span></td>
					<td>
						@if ($value->ptype < 3)
							<span class="label label-info">{{ config('system.progress')[$value->progress] }}</span>
						@endif
					</td>
					<td>
					@if ($value->status == 1)
						<span class="label label-success">{{ config('system.other_order_status')[$value->status] }}</span>
					@elseif ($value->status == 2)
						<span class="label label-info">{{ config('system.other_order_status')[$value->status] }}</span>
					@else 
						<span class="label label-grey">{{ config('system.other_order_status')[$value->status] }}</span>
					@endif
					</td>
					<td class="text-right">
						<div class="toolbar">
							<a href="{{ route('admin.other-order.edit', $value['id']) }}" class="btn-link">修改</a>
							<span class="text-explode ">|</span>
							<a href="javascript:void(0);" data-id="{{ $value['id'] }}" class="btn-link delete-item">删除</a>
						</div>
					</td>
				</tr>
			@endforeach
		@endif
		</tbody>
	</table>
	@if (!$data->isEmpty())
	<table class="table table-footer table-fixed">
		<tfoot>
			<tr>
				<td>
					<div class="pagination-box">
						<div class="pull-right">
							<div class="pagination-info">共有{{ $data->total() }}条， 每页显示：20条</div>
							{!! $data->appends(request()->except('page'))->render() !!}
						</div>
					</div>				
				</td>
			</tr>
		</tfoot>
	</table>
	@else
	<div class="simple-none-data text-center">
		<i class="fa fa-exclamation-circle text-size-20 text-muted" style="vertical-align: middle"></i> 
		<span class="text-size-14 inline-block ml5">没有查询到符合条件的记录</span>
	</div>
	@endif
</div>
@endsection

@section('foot')
<script src="{{ url('js/bootstrap-datetimepicker.js') }}"></script>
<script src="{{ url('js/bootstrap-select/bootstrap-select.min.js') }}"></script>
<script src="{{ url('js/bootstrap-select/defaults-zh_CN.min.js') }}"></script>
<script type="text/javascript">
	$('.datetimepicker-start').datetimepicker({
		language: 'zh-CN',
		autoclose: true,
		minView: 'month'
	});
	$('.datetimepicker-end').datetimepicker({
		language: 'zh-CN',
		autoclose: true,
		minView: 'month'
	});
	$('.selectpicker').selectpicker();
</script>	
@endsection